package org.scirp.ijmis.service.journal.impl;

import java.util.List;

import org.scirp.ijmis.dao.journal.IResearchfieldOfJournalDAO;
import org.scirp.ijmis.po.journal.ResearchfieldOfJournal;
import org.scirp.ijmis.service.journal.IResearchfieldOfJournalService;

public class ResearchfieldOfJournalServiceImpl implements IResearchfieldOfJournalService {
	private IResearchfieldOfJournalDAO researchfieldOfJournalDAO;
	@Override
	public boolean deleteResearchfieldOfJournal(ResearchfieldOfJournal researchfieldOfJournal) {
		return researchfieldOfJournalDAO.deleteResearchfieldOfJournal(researchfieldOfJournal);
	}

	@Override
	public boolean saveResearchfieldOfJournal(ResearchfieldOfJournal researchfieldOfJournal) {
		return researchfieldOfJournalDAO.saveResearchfieldOfJournal(researchfieldOfJournal);
	}

	@Override
	public List<ResearchfieldOfJournal> selectAll() {
		return researchfieldOfJournalDAO.selectAll();
	}

	@Override
	public ResearchfieldOfJournal selectById(long id) {
		return researchfieldOfJournalDAO.selectById(id);
	}

	@Override
	public List<ResearchfieldOfJournal> selectByJournalId(long journalId) {
		return researchfieldOfJournalDAO.selectByJournalId(journalId);
	}

	@Override
	public boolean updateResearchfieldOfJournal(ResearchfieldOfJournal researchfieldOfJournal) {
		return researchfieldOfJournalDAO.updateResearchfieldOfJournal(researchfieldOfJournal);
	}
	public boolean updateJournalResearchfield(Long journalId,List<ResearchfieldOfJournal> researchfieldOfJournalList)
	{
		boolean flag=researchfieldOfJournalDAO.deleteResearchfieldOfJournalByJournalId(journalId);
		if(flag){
			boolean fla=true;
			for(ResearchfieldOfJournal researchfieldOfJournal:researchfieldOfJournalList){
				if(!researchfieldOfJournalDAO.saveResearchfieldOfJournal(researchfieldOfJournal)){
					fla=false;
				}
			}
			return fla;
		}
		else{
			return false;
		}
		
	}
	public IResearchfieldOfJournalDAO getResearchfieldOfJournalDAO() {
		return researchfieldOfJournalDAO;
	}

	public void setResearchfieldOfJournalDAO(IResearchfieldOfJournalDAO researchfieldOfJournalDAO) {
		this.researchfieldOfJournalDAO = researchfieldOfJournalDAO;
	}

}
